package mju.cxf.controller.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import mju.cxf.context.BaseContext;
import mju.cxf.entity.Bill;
import mju.cxf.result.Result;
import mju.cxf.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 账单 前端控制器
 * </p>
 *
 * @author 乐昌新
 * @since 2024-11-14
 */
@RestController
@RequestMapping("/user/api/bill")
public class IBillController {
   @Autowired
    private BillService billService;
   @PostMapping("/list")
    public Result<List<Bill>> listBill() {
       LambdaQueryWrapper<Bill> bqw=new LambdaQueryWrapper<>();
       bqw.eq(Bill::getUserId, BaseContext.getCurrentId()).orderByDesc(Bill::getCreateTime);
       final List<Bill> bills = billService.list(bqw);
       return Result.success(bills);
   }
}
